const sensitiveDB = require("../db/sensitive")

// 敏感词校验
const sensitiveVer = async (text) => {
  const lists = await sensitiveDB.find() || []
  const susceptibleList = lists.map((item) => item.name);

  const isCheck = susceptibleList.some((item) => text?.includes(item));
  if (isCheck) throw '系统检测到您输入的内容包含违规的信息，请审核后再次发表'
}

module.exports = {
  sensitiveVer
}